WEBVTT 00:00.000 --> 00:06.680 It gives me great pleasure to introduce this morning Roman Deuce, who's going to give us 00:06.680 --> 00:08.680 a talk on user acceptance testing. 00:08.680 --> 00:14.680 Please give him a warm welcome. 00:14.680 --> 00:21.800 Thank you very much for joining me here about my talk about automatic acceptance tests for 00:21.800 --> 00:24.660 terminal application. 00:24.660 --> 00:33.080 I thought before I get into the core of it, share a little bit how I structured the presentation. 00:33.080 --> 00:39.680 And I think in the beginning it's probably important to know a little bit of context 00:39.680 --> 00:44.560 about the project, about the terminology, what I mean with acceptance tests and how 00:44.560 --> 00:51.260 they sort of stand out between the other kinds of tests and the motivation of what made us 00:51.260 --> 00:57.280 actually write this kind of test framework. 00:57.280 --> 01:04.240 Specifically then, you know, what lessons we've learned and what we've gained. 01:04.240 --> 01:06.440 Now just quickly about me. 01:06.440 --> 01:07.520 I live in Brisbane. 01:07.520 --> 01:15.360 I've been in the open source world now for almost 20 years, been to conferences for almost 01:15.360 --> 01:16.360 15. 01:16.360 --> 01:20.440 And thinking about it's actually kind of funny. 01:20.440 --> 01:25.720 You can do talks at conferences like for 15 years and you're still nervous. 01:25.720 --> 01:31.320 So who thinks I'd be too nervous to give talks at conferences, please do, because you'd still 01:31.320 --> 01:35.360 be nervous in 15, 20 years' time. 01:35.360 --> 01:38.680 I've worked for a while at Red Hat. 01:38.680 --> 01:46.920 And the reason why I say that some of the procedures and processes I've learned, they're 01:46.920 --> 01:50.960 basically fed back into what I'm presenting today. 01:50.960 --> 01:51.960 So that's kind of important. 01:51.960 --> 02:02.280 At the moment I'm working at an ISP in Brisbane called Superloop on a firewalling appliance. 02:02.280 --> 02:07.340 So a little bit about terminal applications. 02:07.340 --> 02:13.560 So what I mean by terminal applications, I mean the terminal can be a big thing. 02:13.560 --> 02:20.960 And what I mean by is like full terminal text user interfaces as opposed to command line 02:20.960 --> 02:23.360 tools. 02:23.360 --> 02:28.280 You might have heard about LS, LESS or GREP. 02:28.280 --> 02:31.520 These tools you invoke once with arguments. 02:31.520 --> 02:34.720 They do their thing and then basically quit. 02:34.720 --> 02:40.080 Terminal user interfaces are a little bit different because they have their own event loop. 02:40.080 --> 02:47.760 They give you graphical, I would almost say a great graphical UI, depending where you 02:47.760 --> 02:52.240 stand when we talk about terminals. 02:52.240 --> 02:55.480 But they basically they are their own thing. 02:55.480 --> 03:04.280 And when I say that, a former colleague of mine, Fraser, who is sitting in the audience, 03:04.280 --> 03:10.520 and I, we are big fans of terminal applications, especially mail user agents. 03:10.520 --> 03:13.720 We love MUT. 03:13.720 --> 03:20.600 And so we have had some great new ideas about how we would approach this field of mail user 03:20.600 --> 03:23.320 agents in the terminal. 03:23.320 --> 03:25.360 And you know how it is. 03:25.360 --> 03:30.640 We basically decided to write our own in order to implement these ideas. 03:30.640 --> 03:34.760 And that has now been going on the way for like two years, and we called it Pure Bread 03:34.760 --> 03:40.640 as a little homage on MUT. 03:40.640 --> 03:46.920 And just to bring out the point, just a quick demo. 03:46.920 --> 03:51.600 So that's on the side. 03:51.600 --> 03:54.380 That's basically the user interface. 03:54.380 --> 03:56.440 You can scroll through. 03:56.440 --> 04:03.920 You can look in what has happened on the LCA speaker mailing list. 04:03.920 --> 04:05.020 You can search mails. 04:05.020 --> 04:06.020 You can tag mails. 04:06.020 --> 04:15.280 Think a little bit like Google Mail on the terminal. 04:15.280 --> 04:20.620 And when we come to testing these terminal applications due to the fact that they have 04:20.620 --> 04:27.680 basically their own life, there is not really a sophisticated test framework around, especially 04:27.680 --> 04:35.100 not when we started it and current search results are diminishing small. 04:35.100 --> 04:41.520 So in order to like contextualize a little bit what I mean with acceptance tests or testing, 04:41.520 --> 04:50.680 let me basically zoom out when we test applications and start with the biggest approach, which 04:50.680 --> 04:55.320 is basically testing an application as a user would use it. 04:55.320 --> 05:00.440 And we call them, you know, system of black box testing. 05:00.440 --> 05:02.560 You might have heard about Selenium and Puppeteer. 05:02.560 --> 05:06.680 These are like test frameworks for web applications. 05:06.680 --> 05:11.600 And you can basically when you write tests with this framework, you can basically see 05:11.600 --> 05:16.880 how Selenium is basically using your web application as a user would. 05:16.880 --> 05:18.920 You know, like you can input text. 05:18.920 --> 05:24.800 You can click buttons and navigate through the application as if basically a user would 05:24.800 --> 05:26.240 do that. 05:26.240 --> 05:30.360 Just much faster. 05:30.360 --> 05:38.320 Basically those tests have a little bit of a setup cost because it's not really apparent 05:38.320 --> 05:44.640 on how to manipulate the application itself to get it into a state so that you can easily 05:44.640 --> 05:45.640 test it. 05:45.640 --> 05:50.800 So the setup costs are typically higher. 05:50.800 --> 05:57.440 And due to the fact that you basically have two systems like the test itself and the application 05:57.440 --> 06:04.960 itself running side by side, you basically run into like these little intermittent failures, 06:04.960 --> 06:10.960 which I want to talk about later a little bit about the pain points basically. 06:10.960 --> 06:19.640 But these are sort of the, I would say, properties of what we mean by system of black box testing. 06:19.640 --> 06:27.280 Now if we zoom in a little bit and look at components of applications, right, then if 06:27.280 --> 06:33.240 we test those, we have a little bit more control over them on how we set them up and how we 06:33.240 --> 06:35.880 manipulate them so that we can actually test them. 06:35.880 --> 06:42.920 And typically we would refer of those tests as functional integration tests. 06:42.920 --> 06:51.560 Now they are typically less API dependent and they are less maintenance effort in order 06:51.560 --> 06:59.560 to change those if the internal API changes, but they are still kind of dependent on how 06:59.560 --> 07:00.800 they are hooked up. 07:00.800 --> 07:07.840 So they are a little bit better than unit tests, which I come to now because the unit 07:07.840 --> 07:15.360 tests are typically testing the smallest unit in your application like functions and methods. 07:15.360 --> 07:21.120 And they're really quick to write and fast to execute since they are like testing the 07:21.120 --> 07:23.920 smallest possible thing. 07:23.920 --> 07:33.600 And due to that fact, they are typically they help finding and debugging problems very quickly. 07:33.600 --> 07:38.800 As in the opposite side, due to the fact they are so dependent on API changes, they can 07:38.800 --> 07:42.600 be a nightmare to maintain though. 07:42.600 --> 07:50.320 And now what do I mean with acceptance testing? 07:50.320 --> 07:57.560 When we start of implementing certain features, we typically come down to saying these features 07:57.560 --> 08:01.320 should fulfill certain requirements. 08:01.320 --> 08:08.200 And these requirements can be amalgamated as a list of criteria. 08:08.200 --> 08:11.680 So we call them acceptance criteria. 08:11.680 --> 08:18.200 And what I mean by acceptance tests is that we want to basically test the application 08:18.200 --> 08:22.600 as if a user would be using the application. 08:22.600 --> 08:25.960 And you could basically tie this into user stories. 08:25.960 --> 08:29.800 So as a system admin, I would like to perform this in this task. 08:29.800 --> 08:33.960 And that would be an acceptance criteria for this test. 08:33.960 --> 08:39.920 Now obviously this can be carried out by any form of unit integration or system test. 08:39.920 --> 08:49.560 When I say acceptance testing in this talk, I mean system tests. 08:49.560 --> 08:53.760 And when we categorize the testing itself, we also have to look at how the testing is 08:53.760 --> 08:55.000 carried out. 08:55.000 --> 09:02.920 Just quickly, from my experience, they can be carried out by a human manually as well 09:02.920 --> 09:03.920 as automated. 09:03.920 --> 09:12.480 I certainly have seen unit tests carried out by humans as well as being completely automated. 09:12.480 --> 09:14.360 They are obviously ups and downs. 09:14.360 --> 09:24.160 In my experience, humans are really good at finding subtle differences in probing applications. 09:24.160 --> 09:30.200 They are not really good at repetitive work. 09:30.200 --> 09:38.040 Whereas the automated things can be infinitely repeated without typically any problems. 09:38.040 --> 09:40.680 And I want to prove my point. 09:40.680 --> 09:43.200 So on the left we have the manual testing. 09:43.200 --> 09:47.600 On the right we have the repetitive automated testing. 09:47.600 --> 09:53.400 And I'll let him shoe up this melon once again and move on. 09:53.400 --> 10:00.080 But I guess you see what I mean with automated versus manual. 10:00.080 --> 10:11.080 Now why would we want to embark on, you know, automatically test our mailer application or 10:11.080 --> 10:13.680 terminal applications? 10:13.680 --> 10:20.000 Now as I already indicated, Selenium for the terminal unfortunately doesn't exist. 10:20.000 --> 10:26.480 And there is plenty of support if you want to test your command line apps. 10:26.480 --> 10:37.800 But there is almost no support when you want to test your CLI, sorry, your text UI. 10:37.800 --> 10:44.520 Now the typical approach is, well, how about unit testing your terminal application UI? 10:44.520 --> 10:52.480 And if you factor out parts of the application, it is kind of straightforward. 10:52.480 --> 11:00.200 But when it comes to side effects, testing that with unit tests, it's kind of not really 11:00.200 --> 11:07.980 working because typically what you end up with is like you mock out certain side effects 11:07.980 --> 11:17.660 and as much as the application matures, right, the more sort of disjunct those tests become. 11:17.660 --> 11:25.720 And then there's this phenomenon I've experienced is that you have this large test base and 11:25.720 --> 11:32.480 you think like, hmm, I've now changed this feature, but is this test actually still valid? 11:32.480 --> 11:37.120 And you sort of drag it along by make it pass, but you're kind of not really sure if it still 11:37.120 --> 11:42.620 applies but it's still in there and it's basically code you have to maintain. 11:42.620 --> 11:51.600 So it's kind of a tricky story, which basically brings us to TMAX. 11:51.600 --> 11:55.280 TMAX calls itself a terminal multiplexer. 11:55.280 --> 12:03.120 But what it sort of in layman terms what it is is that it allows you to run multiple applications 12:03.120 --> 12:08.360 at the same time in a terminal. 12:08.360 --> 12:15.440 And people of you who might have known New Screen because it's a similar program, what 12:15.440 --> 12:22.360 I want to quickly show you is a TMAX session. 12:22.360 --> 12:27.000 So I'm just emphasizing this a little bit. 12:27.000 --> 12:32.840 Now what you can see at the base here is basically what is so-called a hard line. 12:32.840 --> 12:42.360 And it's basically from TMAX a way to identify first the session on the left. 12:42.360 --> 12:46.840 That's the first session I've opened. 12:46.840 --> 12:53.400 And what you then can see is basically applications running in each window. 12:53.400 --> 13:00.320 And as you can already see, I have like two shells open, bash, and in window three, bash, 13:00.320 --> 13:04.320 as well as an application called WeChat, it's an RLC client. 13:04.320 --> 13:05.320 It's running. 13:05.320 --> 13:08.280 You can change to it. 13:08.280 --> 13:12.180 As well as our terminal mailer. 13:12.180 --> 13:17.320 And what TMAX lets you do now, you can detach from this session. 13:17.320 --> 13:21.320 It's still like all your applications are still running. 13:21.320 --> 13:23.320 You can attach again. 13:23.320 --> 13:24.940 And again, they are still running. 13:24.940 --> 13:30.480 And just for the sake of this talk, I also want to point out that, as I said, this is 13:30.480 --> 13:31.960 a session. 13:31.960 --> 13:35.440 The session is controlled by a TMAX server. 13:35.440 --> 13:39.880 And the TMAX server can control multiple sessions. 13:39.880 --> 13:44.240 And in each session, you have windows where your applications are running. 13:44.240 --> 13:49.520 This is important because I'll be talking more about, you know, TMAX sessions and TMAX 13:49.520 --> 13:51.120 server. 13:51.120 --> 13:57.440 So I hope you follow me so far. 13:57.440 --> 14:04.440 And the reason why we chose TMAX was it was the ideal tool to implement automated testing. 14:04.440 --> 14:08.420 Because A, you can remote control the terminal. 14:08.420 --> 14:12.640 You can remote control every application in a window in TMAX. 14:12.640 --> 14:17.680 You can send input events to these applications. 14:17.680 --> 14:19.320 It even supports mouse events. 14:19.320 --> 14:23.480 So it's easily scriptable, basically. 14:23.480 --> 14:25.080 And the second point is also very important. 14:25.080 --> 14:32.520 It allows you to screenshot or hard copy the contents of each window. 14:32.520 --> 14:36.400 And that is important because, well, you want to know what's going on, right? 14:36.400 --> 14:43.220 And from an automated point of view, you want to, you know, assert against the contents 14:43.220 --> 14:46.640 of what's going on. 14:46.640 --> 14:49.960 And which brings us to the point on how we use TMAX. 14:49.960 --> 14:57.400 Because when we started off, we had this implemented basically in our test code. 14:57.400 --> 15:01.360 And we factored it out as a separate library. 15:01.360 --> 15:07.320 Now we call the Tasty TMAX because there's a little bit of a back story. 15:07.320 --> 15:10.840 And the Haskell world, all of it is implemented in Haskell. 15:10.840 --> 15:18.840 In the Haskell world, Tasty is a test framework which allows you to extend it with plug-ins. 15:18.840 --> 15:28.160 Now this library does not specifically use the Tasty interfaces and Tasty library, but 15:28.160 --> 15:34.760 it leans towards using that test framework. 15:34.760 --> 15:37.200 And so we basically factored it out. 15:37.200 --> 15:38.360 It's now a separate library. 15:38.360 --> 15:39.720 It's called Tasty TMAX. 15:39.720 --> 15:46.800 It allows you to implement acceptance, automated acceptance tests for your application, for 15:46.800 --> 15:49.240 your terminal application. 15:49.240 --> 15:54.600 We use it to test our application. 15:54.600 --> 15:59.200 I want to just quickly show you a demo of how this works. 15:59.200 --> 16:05.160 And I hope everyone can see that. 16:05.160 --> 16:09.000 I'll make this a little bit better. 16:09.000 --> 16:11.200 So please bear with me. 16:11.200 --> 16:13.080 Obviously, it's all text-based. 16:13.080 --> 16:17.280 And due to the fact that I have the font so high now so that people also in the back can 16:17.280 --> 16:20.600 see it, you might not be able to see everything. 16:20.600 --> 16:26.120 But what I'm going to do is I basically run two tests. 16:26.120 --> 16:32.640 And I will show you that I've manipulated one test so that it fails at the end. 16:32.640 --> 16:36.400 So you see what I've already tried that it hopefully works. 16:36.400 --> 16:39.760 You can see part of that over there. 16:39.760 --> 16:46.600 And in the second terminal down below, I will attach to the running test and to observe 16:46.600 --> 16:48.200 what's going to happen. 16:48.200 --> 16:50.760 Obviously, in CI, you'll probably not do that. 16:50.760 --> 16:57.200 But as a developer, it's a nice thing that you can actually observe what's going on. 16:57.200 --> 17:00.400 So I start this test on one side. 17:00.400 --> 17:08.440 In another terminal, you can see down here that there are sessions created. 17:08.440 --> 17:20.840 And now I'll attach to one. 17:20.840 --> 17:26.720 You can basically now see how the application is tested through the test framework, similar 17:26.720 --> 17:32.120 to basically how you would observe Selenium testing your web application. 17:32.120 --> 17:41.060 And due to the fact that I slipped in a little problem, the end of the test fails now with 17:41.060 --> 17:48.680 a raw dump of the terminal as well as a last screen capture to see what happened and what 17:48.680 --> 17:56.840 the last state of the application was. 17:56.840 --> 18:04.720 I want to quickly go about how we've structured the test framework so that you can follow 18:04.720 --> 18:08.920 off what has actually happened. 18:08.920 --> 18:20.840 Basically what we do is we when you use Tasty T-Mux, the Tasty T-Mux library starts a session 18:20.840 --> 18:26.800 and a server, and you need the server which controls the session. 18:26.800 --> 18:32.840 We also additionally start a keep alive session, and that ties into the pitfalls I will mention 18:32.840 --> 18:35.260 later. 18:35.260 --> 18:38.300 We prepare a test environment, and that is application specific. 18:38.300 --> 18:43.200 So that is probably something you will do differently than we do. 18:43.200 --> 18:50.280 So we, for example, set up mailders and set up not much anything which is specific to 18:50.280 --> 18:51.280 our application. 18:51.280 --> 18:58.360 We just do a cleanup code so that if something happens, all resources are cleaned up. 18:58.360 --> 19:10.200 That's kind of how most test frameworks go about their daily job, nothing exotic here. 19:10.200 --> 19:13.040 I wanted to quickly introduce some example code. 19:13.040 --> 19:18.360 Now, how many people are Haskell developers? 19:18.360 --> 19:22.640 All right. 19:22.640 --> 19:27.100 So I have a little proposition for the ones who didn't raise their hands. 19:27.100 --> 19:31.760 If you're curious about Haskell, if you're curious about functional programming, join 19:31.760 --> 19:36.520 us and experience and learn some real world Haskell. 19:36.520 --> 19:42.360 It will teach you interesting lessons about how to go and work with other languages like 19:42.360 --> 19:44.000 TypeScript and Rust. 19:44.000 --> 19:50.520 So if you're curious, please join us contributing to our application, PureBread. 19:50.520 --> 20:01.840 For the ones who raised their hands, also join us and make the program a bit more awesome. 20:01.840 --> 20:04.520 So just a quick sort of rundown. 20:04.520 --> 20:10.120 I don't want to bore you too much with code examples here, but I just want to point out 20:10.120 --> 20:18.640 that this is an example from the library which is thankfully all written down if you would 20:18.640 --> 20:19.640 try it out. 20:19.640 --> 20:21.200 Thanks to Fraser. 20:21.200 --> 20:28.600 But basically what I want to point out, it is a way to refer to the environment which 20:28.600 --> 20:37.720 has been set up, and each test basically sends input, has an assertion next to it what we 20:37.720 --> 20:51.240 expect on the next screen shot, as well as has an annotation of the rundown when the 20:51.240 --> 20:57.520 test runs. 20:57.520 --> 21:04.200 And while the teardown is basically, again, nothing exotic, it basically kills all sessions, 21:04.200 --> 21:09.520 removes any resources which have been set up, and again, that's sort of standard practice 21:09.520 --> 21:16.320 for test frameworks, but there's nothing different here. 21:16.320 --> 21:20.040 One of the things I want to highlight is like the process. 21:20.040 --> 21:27.160 We at Tier 2 is that we run all acceptance tests before we merge any code so that you 21:27.160 --> 21:32.960 can basically figure out whether a merge request actually regresses the application, and so 21:32.960 --> 21:38.040 far that has been proven very useful. 21:38.040 --> 21:48.800 Now I want to quickly come to the lessons learned, aka the pitfalls. 21:48.800 --> 21:57.160 We've got our fair share of timing problems, and I think if you've been automated tests 21:57.160 --> 22:02.720 as well, then you've probably come across these problems as well because they are sort 22:02.720 --> 22:05.320 of the most common. 22:05.320 --> 22:09.960 And as I said, it's typically due to the fact that there are two systems sort of running 22:09.960 --> 22:15.260 side by side, and they need to sort of catch up with each other, and so when they get out 22:15.260 --> 22:21.380 of whack, you can run into these problems as well. 22:21.380 --> 22:26.760 In the web, it's typically if you see if the application shows, for example, a message 22:26.760 --> 22:31.380 which then disappears, that's a great source of where you can run into timing problems 22:31.380 --> 22:39.360 that the test isn't aware that first of all the message appears and disappears for a certain 22:39.360 --> 22:42.440 period of time. 22:42.440 --> 22:47.600 And unfortunately, I really don't have like a silver bullet to tackle this. 22:47.600 --> 22:53.880 In my opinion or in my experience, the best way is really to have like a deep understanding 22:53.880 --> 23:02.360 and to have developers who have the time to get a deep understanding of the application 23:02.360 --> 23:10.480 because you do need to reason about the entire components of your application in order to 23:10.480 --> 23:16.440 create a hypothesis of why this test is randomly failing. 23:16.440 --> 23:22.420 There's a technical, I mean, we can't deploy them for our spare time project Pure Bread, 23:22.420 --> 23:25.760 but there is a little bit of a technical solution too. 23:25.760 --> 23:30.560 You can sort of throw it at if you have access to a lot of VMs, and that's sort of a churn 23:30.560 --> 23:36.720 CI set up where you can basically run the tests in a different order randomly at a different 23:36.720 --> 23:40.480 speed. 23:40.480 --> 23:49.960 We ran into this one which had something to do with T-Mux changing its compatibility between 23:49.960 --> 23:51.080 versions. 23:51.080 --> 23:56.320 And this one was actually interesting because I've put a little example down here. 23:56.320 --> 24:06.520 So you can see the control characters used by T-Mux or printed by T-Mux before and after, 24:06.520 --> 24:11.680 and these were used to basically print Pure Bread with a background. 24:11.680 --> 24:18.800 And so in the old T-Mux set up, it was sort of mangled together, the foreground and the 24:18.800 --> 24:23.840 background colors, whereas the new one separated them sequentially. 24:23.840 --> 24:30.200 And what that meant for the library, it would have to basically be aware of either or and 24:30.200 --> 24:32.440 match against either or. 24:32.440 --> 24:40.360 And that happens because Travelers is still using fairly old distributions with a stable 24:40.360 --> 24:46.440 set of programs, and among them is like an older version of T-Mux than you probably have 24:46.440 --> 24:50.560 on your machine. 24:50.560 --> 24:57.560 We had races, and the reason before why I sort of outline how sort of T-Mux works between 24:57.560 --> 25:03.880 the server and the session is because we had races with the set up and the tier down between 25:03.880 --> 25:05.580 tests. 25:05.580 --> 25:14.600 And it came to be that initially we were running each test in its own session and killed the 25:14.600 --> 25:20.240 session, which also killed the server, and the next test coming along, creating a new 25:20.240 --> 25:22.680 session and creating a new server. 25:22.680 --> 25:28.640 And this overlapping between stopping and killing a server, including the session and 25:28.640 --> 25:34.740 starting it up again sort of meant that these were like stumbling over each other and causing 25:34.740 --> 25:39.280 random failures. 25:39.280 --> 25:46.320 And I should note that in order to avoid these races, we basically now keep a live session 25:46.320 --> 25:55.040 running for the entire test time and basically clean it up once all tests have run. 25:55.040 --> 26:00.080 And there's this fair share of environmental differences, and due to the fact that most 26:00.080 --> 26:06.280 of our environments, whether they are in CI or locally, they are never really pure, you 26:06.280 --> 26:12.920 will probably always run into them, and for the purpose of this talk, especially for terminal 26:12.920 --> 26:20.480 applications, be aware that certain terminals have different support for different amount 26:20.480 --> 26:21.480 of colors. 26:21.480 --> 26:30.000 So some terminals only support 16 colors, 256, 16 bit, et cetera. 26:30.000 --> 26:39.760 So be assertive of what terminal you actually support, and that means what type of colors 26:39.760 --> 26:42.640 you're actually asserting against. 26:42.640 --> 26:48.560 Then there's this fair share of environment variables, which can, you know, expose certain 26:48.560 --> 26:56.160 programs to your test and your application you're maybe not locally aware of. 26:56.160 --> 27:04.120 And last point is this is an interesting thing, the line wrapping in a terminal, just to make 27:04.120 --> 27:09.120 my point. 27:09.120 --> 27:14.480 Every shell has its so-called PS1. 27:14.480 --> 27:23.440 You can see on the left-hand side the directory you're in. 27:23.440 --> 27:32.440 Sometimes you show, for example, sometimes you show, you know, the Git branch you're 27:32.440 --> 27:33.440 in. 27:33.440 --> 27:36.200 Basically, my point is that this line can be arbitrary long. 27:36.200 --> 27:38.160 It can be arbitrary long on your CI server. 27:38.160 --> 27:41.440 It can be arbitrary long on your local environment. 27:41.440 --> 27:47.160 And that, since all of it is text-based, that can already chew up a fair amount of characters. 27:47.160 --> 27:54.160 Now, in your test case, if you assert against a continuous line and that line gets wrapped 27:54.160 --> 28:01.880 at the end of the terminal, it can mean arbitrary failures because in the CI, the line is maybe 28:01.880 --> 28:07.120 longer or locally the line is shorter. 28:07.120 --> 28:09.280 And so you have to be aware of that. 28:09.280 --> 28:16.320 And TMAX has a little switch you can invoke a capture with. 28:16.320 --> 28:21.880 And it's called minus uppercase J to join all lines. 28:21.880 --> 28:26.280 And that allows you to basically assert against continuous wrapped lines. 28:26.280 --> 28:31.680 And that's part we put into library 2. 28:31.680 --> 28:36.200 Not specifically for our purpose. 28:36.200 --> 28:38.960 We didn't run into this specifically. 28:38.960 --> 28:45.000 But I do remember from experience that hardware can be a factor 2. 28:45.000 --> 28:47.160 And that goes back to my time at Red Hat. 28:47.160 --> 28:54.680 I remember there were versions of OpenStack which was provisioning machines with a slightly 28:54.680 --> 28:57.840 off MTU on the network interfaces. 28:57.840 --> 29:03.760 And the weird thing is that in your test, you experience dropouts and timeouts and you 29:03.760 --> 29:07.040 wonder what the hell is going on. 29:07.040 --> 29:12.640 And my point is that whether it's a virtual machine, whether it's like firmware, it's 29:12.640 --> 29:13.720 all software. 29:13.720 --> 29:22.080 And they can't like rarely but they do can also have effects on your application tests. 29:22.080 --> 29:29.980 So for the purpose of completeness, I wanted to point this one out too. 29:29.980 --> 29:35.680 And since we were at the pitfalls, I thought I also mentioned of what you can do to basically 29:35.680 --> 29:37.720 prevent it. 29:37.720 --> 29:46.440 Now protocoling is not really a prevention per se, but it is certainly important to know 29:46.440 --> 29:50.840 what it's going to cost you to fix it. 29:50.840 --> 29:58.300 And so one thing I wanted to point out that if you do have random failures in your tests, 29:58.300 --> 30:01.560 that it's certainly important to protocol all these failures. 30:01.560 --> 30:12.200 So you can basically figure out whether the amount of failures are really worth fixing 30:12.200 --> 30:15.920 if you have like a tight budget, for example. 30:15.920 --> 30:23.440 Little handy tip, attach screenshots to the bug report as well as, you know, log output 30:23.440 --> 30:30.200 because the chances if you put in links is that the one you're linking to has probably 30:30.200 --> 30:35.840 changed in a year and moved on to some other URL and then the bug report is kind of useless 30:35.840 --> 30:42.640 because it's pointing to a resource you can't access anymore. 30:42.640 --> 30:50.440 We do this and again, like that was something I've learned at Red Hat that have CI run all 30:50.440 --> 30:55.080 the tests before you actually merge because it's much easier to figure out that something 30:55.080 --> 31:04.000 regresses your application when you actually merge the pull request rather than later. 31:04.000 --> 31:10.440 And one other thing is it's good to run them, you know, regularly so that you actually find 31:10.440 --> 31:11.440 random failures. 31:11.440 --> 31:16.960 We are running ours now and Travis like, you know, every day and they're like sometimes 31:16.960 --> 31:24.560 random failures popping up we have to look into and find out why they happen. 31:24.560 --> 31:29.360 That goes basically back to what I already mentioned with like a churn CI setup. 31:29.360 --> 31:36.120 If you have access to, you know, these kind of machines, certainly go, you know, use them 31:36.120 --> 31:41.120 and utilize them to, you know, churn through your tests in order to figure out whether 31:41.120 --> 31:48.200 your tests are susceptible to, you know, different order and speed execution. 31:48.200 --> 31:56.320 I also want to point out that especially for a situation where, you know, budget is tight 31:56.320 --> 32:03.840 that it is important to have the time to debug certain failures because not only will this 32:03.840 --> 32:09.400 make you a better engineer in order to reason about your systems and to reason about like 32:09.400 --> 32:17.880 the Linux system as a whole or any kind of system, it also improves a way of how quickly 32:17.880 --> 32:26.560 you can debug problems in the future and that is certainly a really important thing to have. 32:26.560 --> 32:32.760 Quickly about what we gained though and that was actually like for us as a small project 32:32.760 --> 32:38.680 or a spare time project, really, you know, massive, can basically ship when CI is green 32:38.680 --> 32:46.720 and that ties into that you're confident enough that, you know, that the pull request doesn't 32:46.720 --> 32:53.120 request your application and where this ties into as well is that if you're in the sprint 32:53.120 --> 33:00.120 session and you have to estimate some piece of work knowing that your estimate is probably 33:00.120 --> 33:07.080 not influenced by someone else's regression is really good, especially that it makes you 33:07.080 --> 33:18.320 confident that your estimate doesn't, you know, go out of bands massively as opposed 33:18.320 --> 33:21.800 to, you know, patches being merged right in the center and later on you get like the test 33:21.800 --> 33:28.520 feedback of maybe they are causing breakage. 33:28.520 --> 33:36.960 That is specifically to our acceptance tests, specifically to system tests and black box 33:36.960 --> 33:46.240 tests, sorry, that internal changes don't really affect the maintenance of the system 33:46.240 --> 33:52.120 tests because you can still reflect at large if the feature implemented basically stays 33:52.120 --> 33:56.920 the same, well, you expect that it still behaves the same even if it has like more efficient 33:56.920 --> 34:01.680 code and that is a really nice thing to have. 34:01.680 --> 34:06.480 The other thing is that system tests are automated system tests, sorry, automated acceptance 34:06.480 --> 34:13.760 tests can be really fast and I remember I always had conversations with people, yeah, 34:13.760 --> 34:21.720 but they take four hours for a mature application or they, I don't know, take six hours and 34:21.720 --> 34:28.560 I mean fast here as compared to what's the alternative because the typical alternative 34:28.560 --> 34:35.560 is we do have testers who test our application and that can take weeks, right, so you always 34:35.560 --> 34:41.640 have to see this in comparison to what the alternative is and the typical alternatives 34:41.640 --> 34:48.520 I'm aware of are not as fast and not as repetitive. 34:48.520 --> 34:53.600 And as I already indicated, there are obviously benefits to automation in itself, right, so, 34:53.600 --> 34:58.640 you know, like you can repeat them as often as you want. 34:58.640 --> 35:05.520 Automated things can be optimized to be faster, to be more efficient and, yeah, they can be 35:05.520 --> 35:10.640 infinitely repeated. 35:10.640 --> 35:17.880 We did a little look around of what's out there called the competitors. 35:17.880 --> 35:21.400 There's a little bit of enterprise stuff around there. 35:21.400 --> 35:30.800 I found a library called liptmux implement in Python, so if Python folks are out there, 35:30.800 --> 35:34.040 they might want to look at that. 35:34.040 --> 35:42.560 Some seem to be a bend, some seem to be perhaps still maintained, so you've got to judge yourself 35:42.560 --> 35:46.040 whether you want to adopt it or not. 35:46.040 --> 35:55.720 Some future ideas we do have, especially they should be done almost up to the next LCA because 35:55.720 --> 36:01.280 everyone's now joining our project here, I think. 36:01.280 --> 36:07.280 Just kidding, but so we have some ideas about at the moment we use red axis and they behave 36:07.280 --> 36:12.240 differently because they follow different implementations and that is kind of a yucky 36:12.240 --> 36:13.240 thing. 36:13.240 --> 36:20.240 An optimization idea is to run all tests in parallel would be really good. 36:20.240 --> 36:28.800 And one thing I was thinking of was that at the moment we are basically snapshotting the 36:28.800 --> 36:35.680 terminal sort of every x milliseconds and sort of pull the state and I wonder if there's 36:35.680 --> 36:40.920 not a better way to reliably figure out if the terminal has been repainted. 36:40.920 --> 36:46.880 I'm aware there's some kind of way to monitor the terminal from tmux, but I'm not sure if 36:46.880 --> 36:54.840 that is really a good way to figure out if the terminal has been repainted. 36:54.840 --> 36:56.760 Quick some references. 36:56.760 --> 37:04.440 The top link is the link you want to go contributing and learning about Haskell, obviously. 37:04.440 --> 37:07.640 Second link is our library. 37:07.640 --> 37:10.520 Please join plenty. 37:10.520 --> 37:15.960 There is a thing when we were talking about acceptance tests, there is a thing about behavior-driven 37:15.960 --> 37:18.040 development. 37:18.040 --> 37:20.120 You might have heard about Cucumber. 37:20.120 --> 37:25.400 It's a bit of a I would say it's become a little bit of an enterprise thing that you 37:25.400 --> 37:29.920 can basically write a story down and it's something you can give your manager who understands 37:29.920 --> 37:32.000 the story. 37:32.000 --> 37:36.880 It's sort of a similar feel that you can basically communicate what you're testing with your 37:36.880 --> 37:38.880 stakeholders. 37:38.880 --> 37:40.920 Email. 37:40.920 --> 37:48.120 Fraser is more into Twitter than I do, but yeah. 37:48.120 --> 37:53.960 And that is basically the end of my talk and I'm accepting questions. 37:53.960 --> 37:56.280 Thank you. 37:56.280 --> 38:06.040 I just wanted to quickly say thank you to Fraser who helped me a lot putting that talk 38:06.040 --> 38:12.400 together and also helped me a lot learning about Haskell and mentoring me through the 38:12.400 --> 38:13.400 entire time. 38:13.400 --> 38:15.080 Basically, I want to play it forward. 38:15.080 --> 38:21.880 Whoever wants to join, as you can hear, we're desperate for contributors, but whoever wants 38:21.880 --> 38:27.520 to join and learn about the language, please come and join. 38:27.520 --> 38:30.600 One question because you were talking about regexes and those problems. 38:30.600 --> 38:36.880 Is there anything like text, finite state machine, and Haskell? 38:36.880 --> 38:38.520 I'm not specifically aware of Fraser. 38:38.520 --> 38:44.320 Are you aware of... 38:44.320 --> 38:50.880 It's certainly something to look into, especially if we think about, you know, have a better 38:50.880 --> 38:57.840 representation of what the terminal looks like and how we assert certain expectations 38:57.840 --> 39:00.640 against the terminal. 39:00.640 --> 39:08.920 So yeah, there's definitely room for improvement. 39:08.920 --> 39:09.920 Thank you all for coming. 39:09.920 --> 39:10.920 No, there's one. 39:10.920 --> 39:29.160 I was going to say, could you test with something like Parsec or C instead of regex? 39:29.160 --> 39:38.860 We had this idea too that maybe it would make sense to pass the output into sort of a representation 39:38.860 --> 39:46.040 and have a possibility to assert against that, which would probably provide a much richer 39:46.040 --> 39:53.440 way of expressing yourself against what you're expecting. 39:53.440 --> 39:56.440 Something like a DOM or something. 39:56.440 --> 40:00.600 I was thinking you'd go... 40:00.600 --> 40:03.800 Can we see CSS selected? 40:03.800 --> 40:13.440 It depends on who was joining us. 40:13.440 --> 40:16.920 Just like to encourage everyone to give another thank you to Roman. 40:16.920 --> 40:19.920 And as an appreciation, there's one there as well. 40:19.920 --> 40:20.920 Thank you. 40:20.920 --> 40:37.080 Thank you